
import 'package:netstorage/model/search_model_item.dart';

class SearchModel{
  String? keyword;
  bool? success;
  List<SearchModelItem>? data;

  SearchModel({this.keyword,this.success,this.data});

  factory SearchModel.fromJson(Map<String,dynamic> map){
    List<Map<String,dynamic>> mapList = (map['data'] as List?)?.cast<Map<String,dynamic>>() ?? [];
    List<SearchModelItem> modelList = [];

    for(var item in mapList){
      SearchModelItem obj = SearchModelItem.fromJson(item);
      modelList.add(obj);
    }
    return SearchModel(
      keyword: map['keyword'],
        success: map['success'],
      data: modelList
    );
  }

  @override
  String toString() {
    return 'keyword:$keyword,success:$success,data:${data.toString()}';
  }
}